#include<iostream>
#include<cstring>
using namespace std;
const int N = 110, M = N * N;
int h[N], e[M], ne[M], idx;
int low[N], dfn[N], stk[N], top, timestamp;
int ssc_cnt, id[N], sz[N];
int din[N], dout[N];
bool in_stk[N];
int n;
void add(int a, int b)
{
	e[idx] = b, ne[idx] = h[a], h[a] = idx++;
}
void tarjan(int u)
{
	low[u] = dfn[u] = ++timestamp;
	stk[++top] = u, in_stk[u] = 1;
	for (int i = h[u]; ~i; i = ne[i]) {
		int j = e[i];
		if (!dfn[j]) {
			tarjan(j);
			low[u] = min(low[u], low[j]);
		}
		else if (in_stk[j]) {
			low[u] = min(low[u], dfn[j]);
		}
	}
	if (dfn[u] == low[n]) {
		++ssc_cnt;
		int y;
		do {
			y = stk[top--];
			in_stk[y] = 0;
			id[y] = ssc_cnt;
			sz[ssc_cnt] ++;
		} while (y != u);
	}
}
int main()
{
	cin >> n;
	memset(h, -1, sizeof(h));
	for (int i = 1; i <= n; i++) {
		int t;
		while (cin >> t, t) {
			add(i, t);
		}
	}
	for (int i = 1; i <= n; i++) {
		if (!dfn[i]) {
			tarjan(i);
		}
	}
	cout << ssc_cnt << endl;
	for (int i = 1; i <= n; i++) {
		for (int j = h[i]; ~j; j = ne[j]) {
			int k = e[j];
			int a = id[i], b = id[k];
			if (a != b) {
				dout[a]++;
				din[b]++;
			}
		}
	}
	int ans1 = 0, ans2 = 0;
	for (int i = 1; i <= ssc_cnt; i++) {
		if (!din[i])ans1++;
		if (!dout[i])ans2++;
	}
	cout << ans1 << endl;
	if (ssc_cnt == 1)cout << 0 << endl;
	else cout << max(ans1, ans2) << endl;
	return 0;
}